package ender.threads
{
	import ender.managers.ThreadManager;
	
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	import net.digitalprimates.fluint.tests.TestCase;
	
	public class EndingThreadTest extends TestCase
	{
		protected var thread:EndingSimpleThread;
		
		/**
		 * Set up test.
		 */
		override protected function setUp():void {
			ThreadManager.getInstance().debugMode = true;
		} 		
		
		public function testBasicSimpleThread():void {
			thread = new EndingSimpleThread(null, Thread.URGENT_PRIORITY);
			
			thread.start();

			assertEquals(1, ThreadSchedule.threadCount);

			var timer:Timer = new Timer(1500, 1);
			timer.addEventListener(TimerEvent.TIMER_COMPLETE, asyncHandler(onTimerComplete, 5000));
			timer.start();
		}
		
		protected function onTimerComplete(event:TimerEvent, ptd:Object):void {
			assertEquals(0, ThreadSchedule.threadCount);
		}
	}
}